package cn.xzchain.concurrency.singleton;

import cn.xzchain.concurrency.annoations.Recommend;
import cn.xzchain.concurrency.annoations.ThreadSafe;

/**
 * @author lihang
 * @date 2018/5/7.
 * @description 懒汉模式，借助静态内部类,由jvm保证线程安全
 */
@ThreadSafe
@Recommend
public class Singleton8 {

    private Singleton8(){
    }

    private static class InnerSingleton{
        private static final Singleton8 singleton8 = new Singleton8();
    }

    public static final Singleton8 getInstance(){
        return InnerSingleton.singleton8;
    }
}
